package com.youlin.controller;

import com.youlin.dto.BaseDataResDto;
import com.youlin.dto.BaseReqDto;
import com.youlin.dto.BaseResDto;
import com.youlin.dto.Status;
import com.youlin.dto.req.ReviewSignInReqDto;
import com.youlin.dto.res.SIContentResDto;
import com.youlin.dto.res.SINameListResDto;
import com.youlin.dto.res.SINameResDto;
import com.youlin.service.BygSignInService;
import com.youlin.untils.MyBeanUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSort;
import io.swagger.annotations.ApiSort;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@ApiSort(8)
@Api(tags = {"8 - 签到审核模块"})
@RestController
@RequestMapping("/bygReview")
public class BygReviewController {

    @Autowired
    private BygSignInService bygSignInService;

    /**
     * 获取待审核来宾签名列表
     * @return
     */
    @PostMapping("/review/findAllSignInNames")
    @ApiOperationSort(1)
    @ApiOperation(value = "1 - 获取待审核来宾签名列表", notes = "请求参数：data = 预约ID")
    public BaseDataResDto<List<SINameListResDto>> findAllSignInNames (@RequestBody BaseReqDto<Integer> baseReqDto) {
        Integer amId = baseReqDto.getData();
        if (amId == null) return new BaseDataResDto<>(Status.PARAMETERERROR);
        return bygSignInService.findAllSignInNames (amId);
    }

    /**
     * 获取待审核来宾祝福列表
     * @return
     */
    @PostMapping("/review/findAllSignInContents")
    @ApiOperationSort(2)
    @ApiOperation(value = "2 - 获取待审核来宾祝福列表", notes = "请求参数：data = 预约ID")
    public BaseDataResDto<List<SIContentResDto>> findAllSignInContents (@RequestBody BaseReqDto<Integer> baseReqDto) {
        Integer amId = baseReqDto.getData();
        if (amId == null) return new BaseDataResDto<>(Status.PARAMETERERROR);
        return bygSignInService.findAllSignInContents (amId);
    }

    /**
     * 审核来宾签到：来宾签名/来宾留言
     * @return
     */
    @PostMapping("/review/reviewSignIn")
    @ApiOperationSort(3)
    @ApiOperation(value = "3 - 审核来宾签到：来宾签名/来宾留言")
    public BaseResDto reviewSignIn (@RequestBody BaseReqDto<ReviewSignInReqDto> baseReqDto) {
        ReviewSignInReqDto data = baseReqDto.getData();
        if (MyBeanUtil.isParamError(data)) return new BaseResDto(Status.PARAMETERERROR);
        return bygSignInService.reviewSignIn (data.getSiUuIds(), data.getType());
    }
}
